<?php
class model_box extends base_model{
    # 取出用户等级
    public function mod_user_vip(){
        $sql = "SELECT `lid`,`title` FROM `@@userlevel` ORDER BY `lid` ASC";
        $data = $this->db->query($sql,3);
        $args = array();
        foreach ($data as $v){
            $args[$v['lid']] = $v['title'];
        }
        return $args;
    }

    # 用户代理等级
    public function mod_agent_level()
    {
        $sql = "SELECT `lid`,`title` FROM `@@agentlevel` ORDER BY `lid` ASC";
        $data = $this->db->query($sql,3);
        $args = array();
        foreach ($data as $v){
            $args[$v['lid']] = $v['title'];
        }
        return $args;
    }

    # region 发信箱列表
    public function mod_mail_sendlist($args)
    {
        $where_txt = "";
        if(!empty($args['sKey'])){
            $where_txt .= " AND (m.`title` LIKE '%".$args['sKey']."%')";
        }else{
            $fromTime = strtotime($args['fromTime']);
            $toTime = strtotime($args['toTime']) + 86400;
            $where_txt .= " AND m.`actiontime` BETWEEN ".$fromTime." AND ".$toTime."";
        }

        $sql = "SELECT ~field~ FROM `@@mailbox` m WHERE 1 {$where_txt} ~order~ ~limit~";
        //取出当前页的数据
        $sql_arr = array(
            'field' => 'm.`id`,m.`touid`,m.`title`,m.`actiontime`',
            'page_current' => $args['page_current'],
            'pagesize' => $args['ps'],
            'order' => ' ORDER BY m.`actiontime` DESC',
        );
        $datas = $this->getTableRows($sql,$sql_arr);
        return array(
            'datas' => $datas['datas'],
            'record' => $datas['total'],
        );
    }
    # endregon

}